package com.wxp.app;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.wxp.app.activity.Message2Activity;
import com.wxp.app.activity.MessageActivity;
import com.wxp.app.utils.LogUtils;

public class MainActivity extends AppCompatActivity {

    /**
     * 界面创建方法
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        //创建界面
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        //设置布局界面
        setContentView(R.layout.activity_main);
        //设置标题
        TextView textView = findViewById(R.id.main_text);
        //获取自定义字符串  this.getString(字符串变量id)
        LogUtils.info("自定义字符串：%s", this.getString(R.string.ywzq));
        textView.setText(textView.getText() + "\n" + this.getString(R.string.ywzq));

        //设置应用窗口监听器
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        //设置按钮点击时间
        Button button = findViewById(R.id.main_button);
        button.setOnClickListener(v -> {
            //跳转消息界面
            Intent intent = new Intent(MainActivity.this, MessageActivity.class);
            startActivity(intent);
        });
        Button button2 = findViewById(R.id.main_button2);
        button2.setOnClickListener(v -> {
            //跳转消息界面
            Intent intent = new Intent(this, Message2Activity.class);
            startActivity(intent);
        });
    }
}